//
//  DYLoginViewController.m
//  DYHospital
//
//  Created by 胡金东 on 16/3/22.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "DYLoginViewController.h"
#import "ViewController.h"
#import "UIView+Color.h"
#import "DYRegistViewController.h"
#import "DYForgetViewController.h"

@interface DYLoginViewController ()

@end

@implementation DYLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"登录";
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    [self leftBackBtn];
    [self resigerBtn];
    [self setupText];
    
}

-(void)leftBackBtn
{
    UIBarButtonItem *leftBaBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back_Arrow"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBackBtnClick)];
    [leftBaBtn setTintColor:[UIColor blackColor]];
    self.navigationItem.leftBarButtonItem = leftBaBtn;
}
-(void)leftBackBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)resigerBtn
{
    UIBarButtonItem *resBtn = [[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(resigerBtnClick)];
    [resBtn setTintColor:[UIColor blackColor]];
    self.navigationItem.rightBarButtonItem = resBtn;
}
//注册
-(void)resigerBtnClick
{
    DYRegistViewController *registVC = [[DYRegistViewController alloc]init];
    [self.navigationController pushViewController:registVC animated:YES];
    
}

-(void)setupText
{
        
    UITextField *phoneText = [[UITextField alloc]initWithFrame:CGRectMake(20, 64+25, [UIScreen mainScreen].bounds.size.width - 40, 35)];
    phoneText.placeholder = @" 请输入手机号";
    [phoneText setBackgroundColor:[UIColor whiteColor]];
    [phoneText setRadius:5 borderWith:0 borderColor:[UIColor clearColor]];
    phoneText.keyboardType = UIKeyboardTypeDecimalPad;//数字
    phoneText.clearButtonMode = UITextFieldViewModeUnlessEditing;//全消（小X）
    [self.view addSubview:phoneText];
    UITextField *passwordText = [[UITextField alloc]initWithFrame:CGRectMake(20, 64+70, [UIScreen mainScreen].bounds.size.width - 40, 35)];
    passwordText.placeholder = @" 请输入密码";
    [passwordText setBackgroundColor:[UIColor whiteColor]];
    [passwordText setRadius:5 borderWith:0 borderColor:[UIColor clearColor]];
    passwordText.clearButtonMode = UITextFieldViewModeUnlessEditing;
    [self.view addSubview:passwordText];
    
    UIButton *forgetBtn = [[UIButton alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 105, 64+115, 100, 15)];
    [forgetBtn setTitle:@"忘记密码？" forState:UIControlStateNormal];
    forgetBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [forgetBtn addTarget:self action:@selector(forgetBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:forgetBtn];
    
    UIButton *loginBtn = [[UIButton alloc]initWithFrame:CGRectMake(20, 64+190, [UIScreen mainScreen].bounds.size.width - 40, 40)];
    [loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [loginBtn setBackgroundColor:[UIColor magentaColor]];
    [loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [loginBtn setRadius:5 borderWith:0 borderColor:[UIColor clearColor]];
    [self.view addSubview:loginBtn];
    
}
//登录成功后跳转
-(void)loginBtnClick
{
    
    ViewController *VC = [[ViewController alloc]init];
    [self.navigationController pushViewController:VC animated:NO];
    
}
//忘记密码
-(void)forgetBtnClick
{
    DYForgetViewController *forgetVC = [[DYForgetViewController alloc]init];
    [self.navigationController pushViewController:forgetVC animated:YES];
}
@end
